package com.tingyuge.base.thread.concurrent2;

import java.util.Random;

/**
 * Created by xiaodao
 * date: 2019/11/26
 */
public class MyTest1 {
    public static void main(String[] args) {
        Runnable r = new MyThread();

        Thread t1 =  new Thread(r);
        Thread t2 =  new Thread(r);
        t1.start();
        t2.start();


    }
}

class MyThread implements Runnable{

 int x;
    @Override
    public    void run() {

        x=0;
        while (true){
            System.out.println("result:"+ x++);
            try {
                Thread.sleep(new Random().nextInt(1000));
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(x==30){
                break;
            }
        }
    }
}